def factorial(n): |
else: |
return 2 |
print(factorial(4)) |
if n == 2: |
return n * factorial(n-1) |
def factorial(n): |
    else: |
        return 2 |
print(factorial(4)) |
    if n == 2: |
        return n * factorial(n-1) |
1 | def factorial(n): |
2 |     if n == 2: |
3 |         return 2 |
4 |     else: |
5 |         return n * factorial(n-1) |
6 | print(factorial(4)) |
if len(arr) == 1: |
else: |
return arr[0] |
print(sumOfItems([4,3,2,1])) |
return arr[0] + sumOfItems(arr[1:]) |
def sumOfItems(arr): |
    if len(arr) == 1: |
    else: |
        return arr[0] |
print(sumOfItems([4,3,2,1])) |
        return arr[0] + sumOfItems(arr[1:]) |
def sumOfItems(arr): |
1 | def sumOfItems(arr): |
2 |     if len(arr) == 1: |
3 |         return arr[0] |
4 |     else: |
5 |         return arr[0] + sumOfItems(arr[1:]) |
6 | print(sumOfItems([4,3,2,1])) |
print(lengthOfString("hello")) |
if s == "": |
return 0 |
else: |
return 1 + lengthOfString(s[1:]) |
def lengthOfString(s): |
print(lengthOfString("hello")) |
    if s == "": |
        return 0 |
    else: |
        return 1 + lengthOfString(s[1:]) |
def lengthOfString(s): |
1 | def lengthOfString(s): |
2 |     if s == "": |
3 |         return 0 |
4 |     else: |
5 |         return 1 + lengthOfString(s[1:]) |
6 | print(lengthOfString("hello")) |
if n == 2: |
def sum(n): |
else: |
print(sum(5)) |
return n + sum(n-1) |
return 2 |
    if n == 2: |
def sum(n): |
    else: |
print(sum(5)) |
        return n + sum(n-1) |
        return 2 |
1 | def sum(n): |
2 |     if n == 2: |
3 |         return 2 |
4 |     else: |
5 |         return n + sum(n-1) |
6 | print(sum(5)) |
return palindrome(string[1:-1]) |
return True |
return False |
else: |
if len(string) <= 1: |
if string[0] != string[-1]: |
print(palindrome("carrace")) |
def palindrome(string): |
        return palindrome(string[1:-1]) |
        return True |
        return False |
    else: |
    if len(string) <= 1: |
    if string[0] != string[-1]: |
print(palindrome("carrace")) |
def palindrome(string): |
1 | def palindrome(string): |
2 |     if len(string) <= 1: |
3 |         return True |
4 |     if string[0] != string[-1]: |
5 |         return False |
6 |     else: |
7 |         return palindrome(string[1:-1]) |
8 | print(palindrome("carrace")) |
if num == "": |
def binaryConvert(num): |
return 2 ** (len(num) - 1) + binaryConvert(num[1:]) |
elif num[0] == "1": |
return 0 + binaryConvert(num[1:]) |
print(binaryConvert("10101111")) |
return 0 |
else: |
    if num == "": |
def binaryConvert(num): |
        return 2 ** (len(num) - 1) + binaryConvert(num[1:]) |
    elif num[0] == "1": |
        return 0 + binaryConvert(num[1:]) |
print(binaryConvert("10101111")) |
        return 0 |
    else: |
1 | def binaryConvert(num): |
2 |     if num == "": |
3 |         return 0 |
4 |     elif num[0] == "1": |
5 |         return 2 ** (len(num) - 1) + binaryConvert(num[1:]) |
6 |     else: |
7 |         return 0 + binaryConvert(num[1:]) |
8 | print(binaryConvert("10101111")) |
return str(rem) |
print(denaryConvert(175)) |
rem = num % 2 |
def denaryConvert(num): |
return denaryConvert(new) + str(rem) |
new = num //2 |
else: |
if new != 0: |
        return str(rem) |
print(denaryConvert(175)) |
    rem = num % 2 |
def denaryConvert(num): |
        return denaryConvert(new) + str(rem) |
    new = num //2 |
    else: |
    if new != 0: |
1 | def denaryConvert(num): |
2 |     new = num //2 |
3 |     rem = num % 2 |
4 |     if new != 0: |
5 |         return denaryConvert(new) + str(rem) |
6 |     else: |
7 |         return str(rem) |
8 | print(denaryConvert(175)) |
return 0 |
print(multiArraySum([5,4,1,[5,2,1],[4,[4]]])) |
return multiArraySum(num[0]) + multiArraySum(num[1:]) |
elif type(num[0]) == list: |
else: |
if len(num) == 0: |
return num[0] + multiArraySum(num[1:]) |
def multiArraySum(num): |
        return 0 |
print(multiArraySum([5,4,1,[5,2,1],[4,[4]]])) |
        return multiArraySum(num[0]) + multiArraySum(num[1:]) |
    elif type(num[0]) == list: |
    else: |
    if len(num) == 0: |
        return num[0] + multiArraySum(num[1:]) |
def multiArraySum(num): |
1 | def multiArraySum(num): |
2 |     if len(num) == 0: |
3 |         return 0 |
4 |     elif type(num[0]) == list: |
5 |         return multiArraySum(num[0]) + multiArraySum(num[1:]) |
6 |     else: |
7 |         return num[0] + multiArraySum(num[1:]) |
8 | print(multiArraySum([5,4,1,[5,2,1],[4,[4]]])) |
else: |
elif type(num[0]) == list: |
def flatten(num): |
return [num[0]] + flatten(num[1:]) |
print(flatten([5,4,1,[5,2,1],[4,[4]]])) |
if len(num) == 0: |
return flatten(num[0]) + flatten(num[1:]) |
return [] |
    else: |
    elif type(num[0]) == list: |
def flatten(num): |
        return [num[0]] + flatten(num[1:]) |
print(flatten([5,4,1,[5,2,1],[4,[4]]])) |
    if len(num) == 0: |
        return flatten(num[0]) + flatten(num[1:]) |
        return [] |
1 | def flatten(num): |
2 |     if len(num) == 0: |
3 |         return [] |
4 |     elif type(num[0]) == list: |
5 |         return flatten(num[0]) + flatten(num[1:]) |
6 |     else: |
7 |         return [num[0]] + flatten(num[1:]) |
8 | print(flatten([5,4,1,[5,2,1],[4,[4]]])) |
return fibonacci(n - 1) + fibonacci(n - 2) |
return n |
print(fibonacci(10)) |
def fibonacci(n): |
if n <= 1: |
    return fibonacci(n - 1) + fibonacci(n - 2) |
        return n |
print(fibonacci(10)) |
def fibonacci(n): |
    if n <= 1: |
1 | def fibonacci(n): |
2 |     if n <= 1: |
3 |         return n |
4 |     return fibonacci(n - 1) + fibonacci(n - 2) |
5 | print(fibonacci(10)) |
print(gcd(10,5)) |
return gcd(b, a % b) |
if b == 0: |
return a |
def gcd(a, b): |
print(gcd(10,5)) |
    return gcd(b, a % b) |
    if b == 0: |
        return a |
def gcd(a, b): |
1 | def gcd(a, b): |
2 |     if b == 0: |
3 |         return a |
4 |     return gcd(b, a % b) |
5 | |
6 | print(gcd(10,5)) |